package com.ccctop.cloud.handler;

import com.ccctop.crowd.entity.po.TFundRequestInfo;
import com.ccctop.cloud.service.api.TFundRequestInfoService;
import com.ccctop.crowd.util.ResultEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TFundRequestInfo)表控制层
 *
 * @author makejava
 * @since 2022-03-07 14:30:00
 */
@RestController
public class TFundRequestInfoController {
    /**
     * 服务对象
     */
    @Resource
    private TFundRequestInfoService tFundRequestInfoService;


    @RequestMapping("fund/info/insert")
    public ResultEntity<TFundRequestInfo> insert(@RequestBody TFundRequestInfo info) {
        try{
            return ResultEntity.successWithData(tFundRequestInfoService.insert(info));
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

    @RequestMapping("fund/info/selectByProjectId")
    public ResultEntity<TFundRequestInfo> selectByProjectId(@RequestParam Integer projectId) {
        try{
            TFundRequestInfo data = tFundRequestInfoService.selectByProjectId(projectId);
            return ResultEntity.successWithData(data);
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

    @RequestMapping("fund/info/selectById")
    public ResultEntity<TFundRequestInfo> selectFundRequestInfoById(@RequestParam Integer id) {
        try{
            TFundRequestInfo data = tFundRequestInfoService.selectById(id);
            return ResultEntity.successWithData(data);
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

    @RequestMapping("fund/info/update")
    public ResultEntity<String> update(@RequestBody TFundRequestInfo info) {
        try{
            tFundRequestInfoService.update(info);
            return ResultEntity.successWithoutData();
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

    @RequestMapping("fund/info/agreeIncrease")
    public ResultEntity<String> agreeIncrease(@RequestParam("itemId") Integer itemId) {
        try{
            tFundRequestInfoService.agreeIncrease(itemId);
            return ResultEntity.successWithoutData();
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

    @RequestMapping("fund/info/refuseIncrease")
    public ResultEntity<String> refuseIncrease(@RequestParam("itemId") Integer itemId) {
        try{
            tFundRequestInfoService.refuseIncrease(itemId);
            return ResultEntity.successWithoutData();
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

}